import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import {registryTemplate} from './render/index.js'
import {appPort} from './config/setting.js'
import {route} from './router/index.js'
import koaStatic from 'koa-static'
import {sync} from './db/index.js'


await sync();

const app =new Koa();

app.use(koaStatic('./statics'))

//解析post请求数据挂载到body
app.use(bodyParser())

//注册模板引擎方便使用
app.use(registryTemplate())


//注册路由功能
app.use(route)


app.listen(appPort)

console.log(`服务运行于：http://localhost:${appPort}`);

